package fr.univ.lr.icone.unit;

import java.util.ArrayList;

import org.junit.Assert;
import org.junit.Test;

import fr.univ.lr.icone.agents.Agent;
import fr.univ.lr.icone.configuration.Configuration;

public class ConfigurationTestCase {

	private Configuration config = new Configuration("test_configuration.xml");

	@Test
	public void testLoadConfiguration() {
		config.loadConfiguration();
		Assert.assertEquals(5, Configuration.getAgentNumber());
	}

	@Test
	public void testGetCoordX() {
		config.loadConfiguration();
		ArrayList<Integer> coordsX = config.getCoordX();
		Assert.assertEquals(5, coordsX.size());
	}

	@Test
	public void testGetCoordY() {
		config.loadConfiguration();
		ArrayList<Integer> coordsY = config.getCoordY();
		Assert.assertEquals(5, coordsY.size());
	}

	@Test
	public void testGetGridSize() {
		config.loadConfiguration();
		Assert.assertEquals(40, Configuration.getGridSize());
	}

	@Test
	public void testGetPas() {
		config.loadConfiguration();
		Assert.assertEquals(1, Configuration.getPas());
	}

	@Test
	public void testGetAgentNumber() {
		config.loadConfiguration();
		Assert.assertEquals(5, Configuration.getAgentNumber());
	}

	@Test
	public void testGetAgentList() throws Exception {
		config.loadConfiguration();
		ArrayList<Agent> agents = config.getAgentList();

		/* Comparison Agents List */
		ArrayList<Agent> comparisonAgents = new ArrayList<Agent>();
		comparisonAgents.add(new Agent(1, 0, 3, 12, 15));
		comparisonAgents.add(new Agent(2, 2, 3, 22, 4));
		comparisonAgents.add(new Agent(3, 7, 2, 3, 17));
		comparisonAgents.add(new Agent(4, 7, 3, 23, 3));
		comparisonAgents.add(new Agent(5, 9, 1, 4, 24));

		Assert.assertEquals(agents.size(), comparisonAgents.size());

		for (int i = 0; i < agents.size(); i++) {
			Assert.assertEquals(agents.get(i), comparisonAgents.get(i));
		}
	}

	@Test
	public void testGetTimeLog() {
		config.loadConfiguration();
		Assert.assertEquals(20000, Configuration.getTimeLog());
	}

	@Test
	public void testSaveConfiguration() {

	}
}
